<div class="row-fluid sortable ui-sortable">
	<div id="list-peternakan" class="box span6">
		<div class="box-header well" data-original-title>
			<h2><i class="icon-home"></i> Data Jenis Sapi</h2>
			<div class="box-icon">
				<a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
			</div>
		</div>
		<div class="box-content">
			<table class="table table-striped table-bordered bootstrap-datatable datatable">
				<thead>
					<tr>
						<th>Nama</th>
						<th>Berat Normal</th>
						<th>Panjang Normal</th>
						<th>Tinggi Normal</th>
						<th style="width:77px;!important">Action</th>
					</tr>
				</thead>   
				<tbody>
				<?php	
					if($jenis_sapi){
						foreach($jenis_sapi->result_array() as $data){
							echo "
								<tr>
									<td class='nama".$data["ID_SAPI"]."'>".$data["NAMA"]."</td>
									<td class='berat".$data["ID_SAPI"]."'>".$data["BERAT_NORMAL"]."</td>
									<td class='panjang".$data["ID_SAPI"]."'>".$data["PANJANG_NORMAL"]."</td>
									<td class='tinggi".$data["ID_SAPI"]."'>".$data["TINGGI_NORMAL"]."</td>
									<td class='center'>
										<a class='btn btn-info edit-list' title='Edit' onclick='editJenisSapi(".$data['ID_SAPI'].",\"false\");'>
											<i class='icon-edit icon-white'></i>                                   
										</a>
										<a class='btn btn-danger hapus-list' title='Delete' onclick='deleteJenisSapi(".$data['ID_SAPI'].");'>
											<i class='icon-trash icon-white'></i> 
										</a>
									</td>
								</tr>
							";
						}
					}
				?>
				</tbody>
			</table>            
		</div>
	</div>
	
	<div id="list-daging" class="box span6">
		<div class="box-header well" data-original-title>
			<h2><i class="icon-home"></i> Data Daging Sapi</h2>
			<div class="box-icon">
				<a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
			</div>
		</div>
		<div class="box-content">
			<table class="table table-striped table-bordered bootstrap-datatable datatable">
				<thead>
					<tr>
						<th>Nama</th>
						<th>Info</th>
						<th style="width:77px;!important">Action</th>
					</tr>
				</thead>   
				<tbody>
				<?php
					if($daging_sapi){
						foreach($daging_sapi->result_array() as $data){
							echo "
								<tr>
									<td class='nama".$data["ID_SAPI"]."'>".$data["NAMA"]."</td>
									<td class='info".$data["ID_SAPI"]."'>".$data["INFO_DAGING"]."</td>
									<td class='center'>
										<a class='btn btn-info edit-list' title='Edit' onclick='editDagingSapi(".$data['ID_SAPI'].",\"false\");'>
											<i class='icon-edit icon-white'></i>                                   
										</a>
										<a class='btn btn-danger hapus-list' title='Delete' onclick='deleteDagingSapi(".$data['ID_SAPI'].");'>
											<i class='icon-trash icon-white'></i> 
										</a>
									</td>
								</tr>
							";
						}
					}
				?>
				</tbody>
			</table>            
		</div>
	</div>
</div>
<script>
	function editDagingSapi(id){
		$("body").animate({scrollTop:0});
		$("#id-daging-sapi").val(id);
		$("#nama-daging").val($(".nama"+id).html());
		$("#info-daging").val($(".info"+id).html());
		$('#form-tambah-daging-sapi').attr("action","<?php echo base_url(); ?>sapi/ubah_daging_sapi");
		$('#action-daging-sapi').html("Ubah Data Daging Sapi");
	}
	
	function editJenisSapi(id){
		$("body").animate({scrollTop:0});
		$("#id-jenis-sapi").val(id);
		$("#nama-jenis").val($(".nama"+id).html());
		$("#berat-normal").val($(".berat"+id).html());
		$("#panjang-normal").val($(".panjang"+id).html());
		$("#tinggi-normal").val($(".tinggi"+id).html());
		$('#form-tambah-jenis-sapi').attr("action","<?php echo base_url(); ?>sapi/ubah_jenis_sapi");
		$('#action-jenis-sapi').html("Ubah Data Jenis Sapi");
	}
	
	function deleteDagingSapi(id){
		$.ajax({
			url: "<?php echo base_url(); ?>sapi/hapus_daging_sapi",
			type: "POST",
			data: "id-sapi="+id,
			success: function(msg){
				if(msg=="true") window.location = "<?php echo base_url(); ?>sapi";
			}
		});
	}
	
	function deleteJenisSapi(id){
		$.ajax({
			url: "<?php echo base_url(); ?>sapi/hapus_jenis_sapi",
			type: "POST",
			data: "id-sapi="+id,
			success: function(msg){
				if(msg=="true") window.location = "<?php echo base_url(); ?>sapi";
			}
		});
	}
</script>

